package top.roadvast.springboot.base64_test.utils;

import org.bouncycastle.util.encoders.Base64;

import java.nio.charset.StandardCharsets;

/**
 * 使用castle工具类实现base64加密解密
 */
public class CastleBase64Util {
    public static String encode(String str) {
        return  Base64.toBase64String(str.getBytes(StandardCharsets.UTF_8));
    }

    public static String decode(String src) {
        byte[] decode = Base64.decode(src.getBytes(StandardCharsets.UTF_8));
        return new String(decode, StandardCharsets.UTF_8);
    }
}